// select.js
var WxParse = require('../../utils/wxParse/wxParse.js');
var app = getApp()
var host = app.globalData.host
var img = app.globalData.image
Page({
  data: {
    id:''
  },
  onLoad: function (options) {
    var that = this
    var id = options.id
    that.setData({
      id:id,
      img:img
    })
    wx.request({
      url: host + '/OperationApi/selSelectedContentDtl?id='+ id,
      header: { 'content-type': 'application/json' },
      success:function(res){
        console.log(res)
        that.setData({
          titlephoto:res.data.data.photo,
          titletitle: res.data.data.title,
          titledescri: res.data.data.simpleDescription,
          wedrecom:res.data.data.listSpu,
          liststory: res.data.data.listOtherStories
        })

        var article = res.data.data.description.replace(/\/kaaction/g, img + "/kaaction")
        article = article.replace(/&amp;/g, "&");
        article = article.replace(/&quot;/g, "\"");
        article = article.replace(/&lt;/g, "<");
        article = article.replace(/&gt;/g, ">");
        WxParse.wxParse('article3', 'html', article, that, 5);

      }
    })
  },
  // 从精选跳转至精选
  toselect: function (event) {
    var storyid = event.currentTarget.dataset.id
    wx.redirectTo({
      url: 'select?id=' + storyid,
    })
  },
  // 精选中的商品跳转至购买
  towedproductdetail:function(event){
    var wedid = event.currentTarget.dataset.wedid
    wx.redirectTo({
      url: '../wedproductdetail/wedproductdetail?id=' + wedid,
    })
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
    
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
  
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
  
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
  
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
  
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
  
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
  
  }
})